package com.example.demo.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * @Author: liull
 * @Description: 校验ipv4地址的合法性 每一位为8位无符号整数
 * @Date: Created in 12:01 2020/4/1
 * @Modified By:
 */
public class Main40 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        //        System.out.println(Arrays.toString("127.0.0.1".split("\\.")));
        while ((line = br.readLine()) != null) {
            System.out.println(isLegal(line));
        }
    }

    private static String isLegal(String line) {
        String[] ipStrArray = line.trim().split("\\.");
        if (ipStrArray.length != 4 || line.trim().contains(" ")) {
            return "NO";
        } else {
            for (int i = 0; i < ipStrArray.length; i++) {
                if (Integer.parseInt(ipStrArray[i]) > 255 || Integer.parseInt(ipStrArray[i]) < 0) {
                    return "NO";
                }
            }
            return "YES";
        }

    }
}
